function Mate_Code()
{
	var buffer = new StringBuffer();
	buffer.append('<div class="title"><div class="back"></div><div class="name">同事</div><div class="tool"></div></div>');
	buffer.append('<div id="find" class="finds2"><div class="searchinput ui-border-radius"><input id="keyword" class="bordersolid" type="text" value="" onblur="Show_Search()" onkeyup="WorkMate_Search();"/><div id="searchicon" class="searchicon"><img src="img/jing.jpg"/></div><div id="searchicons" class="searchicons"><img src="img/jings.jpg"/></div></div></div>'); 
	buffer.append('<div class="search border-bottom">');
		buffer.append('<div class="search_content">');
			buffer.append('<div class="search_line"><div class="search_square ui-border-radius">A</div></div>');
			buffer.append('<div class="search_line"><div class="search_square ui-border-radius">B</div></div>');
			buffer.append('<div class="search_line"><div class="search_square ui-border-radius">C</div></div>');
			buffer.append('<div class="search_line"><div class="search_square ui-border-radius">D</div></div>');
			buffer.append('<div class="search_line"><div class="search_square ui-border-radius">E</div></div>');
			buffer.append('<div class="search_line"><div class="search_square ui-border-radius">F</div></div>');
			buffer.append('<div class="search_line"><div class="search_square ui-border-radius">G</div></div>');
			buffer.append('<div class="search_line"><div class="search_square ui-border-radius">H</div></div>');
			buffer.append('<div class="search_line"><div class="search_square ui-border-radius">I</div></div>');
			buffer.append('<div class="search_line"><div class="search_square ui-border-radius">J</div></div>');
			buffer.append('<div class="search_line"><div class="search_square ui-border-radius">K</div></div>');
			buffer.append('<div class="search_line"><div class="search_square ui-border-radius">L</div></div>');
			buffer.append('<div class="search_line"><div class="search_square ui-border-radius">M</div></div>');
			buffer.append('<div class="search_line"><div class="search_square ui-border-radius">N</div></div>');
			buffer.append('<div class="search_line"><div class="search_square ui-border-radius">O</div></div>');
			buffer.append('<div class="search_line"><div class="search_square ui-border-radius">P</div></div>');
			buffer.append('<div class="search_line"><div class="search_square ui-border-radius">Q</div></div>');
			buffer.append('<div class="search_line"><div class="search_square ui-border-radius">R</div></div>');
			buffer.append('<div class="search_line"><div class="search_square ui-border-radius">S</div></div>');
			buffer.append('<div class="search_line"><div class="search_square ui-border-radius">T</div></div>');
			buffer.append('<div class="search_line"><div class="search_square ui-border-radius">U</div></div>');
			buffer.append('<div class="search_line"><div class="search_square ui-border-radius">V</div></div>');
			buffer.append('<div class="search_line"><div class="search_square ui-border-radius">W</div></div>');
			buffer.append('<div class="search_line"><div class="search_square ui-border-radius">X</div></div>');
			buffer.append('<div class="search_line"><div class="search_square ui-border-radius">Y</div></div>');
			buffer.append('<div class="search_line"><div class="search_square ui-border-radius">Z</div></div>');
		buffer.append('</div>');
	buffer.append('</div>');
	buffer.append('<div id="content" class="content" style="margin-top: 143px;">');
		buffer.append('<ul id="matelist">');
		buffer.append('<div class="loading"><img src="img/loading.gif"/></div>');
		buffer.append('</ul>');
	buffer.append('</div>');
	return buffer.toString();
};

function Mate_Data1(data)
{
	var buffer = new StringBuffer();
	$.each(data,function(i,info){
		buffer.append('<li char="'+info.FirstChar+'" realname="'+info.RealName+'" enname="'+info.EnName+'" userid="'+info.ID+'" class="list"><div class="line border-bottom"><div class="icon"><img src="'+info.HeadImg+'"></div><div class="name">'+info.RealName+'</div><div class="detail">'+info.DepartName+'</div></div></li>');
	});
	return buffer.toString();
};

function Show_Search()
{
	if($("#keyword").val()==""){
		$("#searchicon").show();
		$("#searchicons").hide();
		$("#keyword").attr("placeholder",""); 
	}
};

function Show_Search2()
{
	if($("#keyword2").val()==""){
		$("#searchicon2").show();
		$("#searchicons2").hide();
		$("#keyword2").attr("placeholder",""); 
	}
};

//本地搜索
function WorkMate_Search() {
    
    var keyword = $("#keyword").val();
    if (keyword.Trim() != "") {
        $("#matelist .list").addClass("hidden");
        $("#matelist .list[realname*='" + keyword + "']").removeClass("hidden");
        $("#matelist .list[enname*='" + keyword + "']").removeClass("hidden");
    } else {
        $("#matelist .list").removeClass("hidden");
    }
    var count = $("#matelist .list:not([class*='hidden'])").length;
    if (count == 0) {
        if ($("#matelist .nodata").length == 0) {
            $("#matelist").append('<div class="nodata">主人，没有找到相关同事！</div>');
        } else {
            $("#matelist .nodata").show();
        }
    }
    else {
        $("#matelist .nodata").hide();
    }
};

function Init_MateClick() { 
	/*
	mui("#matelist").on("tap","li",function() {
		OpenWindow(1,"同事资料","",null);
		var data = {};
		data.act="One_User";
		data.id = $(this).attr("userid");
		data.comid=comid;
		data.source=source;
		mui.getJSON(oa_domain, data, function(json) {
			$("#contentlist1").html(MateInfo_Code(json.data.user)); 
			$("#divmsg1").append('<div class="smsandphone border-top"><a href="sms:'+json.data.user.UserName+'"><button class="button1 blue" onclick="plus.device.vibrate(100);">发短信</button></a><a href="tel:'+json.data.user.UserName+'"><button class="button2 blue" onclick="plus.device.vibrate(100);">打电话</button></a></div>');
			Init_MateInfo();
		});
	});
	*/
	mui("#matelist").on("tap","li",function() {
		OpenWindow(1,"同事资料","",null);
		CrmOneData($(this).attr("userid"),function(info){
			$("#contentlist1").html(MateInfo_Code(info)); 
			$("#divmsg1").append('<div class="smsandphone border-top"><a href="sms:'+info.UserName+'"><button class="button1 blue" onclick="plus.device.vibrate(100);">发短信</button></a><a href="tel:'+info.UserName+'"><button class="button2 blue" onclick="plus.device.vibrate(100);">打电话</button></a><button id="savephone" class="button3 blue" onclick="plus.device.vibrate(100);">保存至通讯录</button></div>');
			Init_MateInfo();
			
						var phone=info.UserName;
						var name=info.RealName;
						get("savephone").addEventListener("tap",function(){
							plus.contacts.getAddressBook( plus.contacts.ADDRESSBOOK_PHONE, function( addressbook ) {
								// 可通过addressbook进行通讯录操作
								var contact = addressbook.create();
									contact.name = {givenName:name};
									contact.phoneNumbers = [{type:"mobile",value:phone,preferred:true}];
									contact.save( function () {
										plus.nativeUI.toast("已成功保存至通讯录");
									}, function ( e ) {
										plus.nativeUI.toast("保存失败");
									} );
								}, function ( e ) {
									plus.nativeUI.toast("保存失败");
							});
	
						});
		});
	});
	
};